package com.learn.xueer.ui.activity

import android.os.Bundle
import androidx.lifecycle.Observer
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.learn.xueer.app.base.BaseActivity
import com.learn.xueer.data.model.bean.BookInfo
import com.learn.xueer.data.model.bean.Notice
import com.learn.xueer.databinding.ActivityContactServerBinding
import com.learn.xueer.databinding.ActivityInnerMessageBinding
import com.learn.xueer.databinding.ActivityMessageBinding
import com.learn.xueer.ui.adapter.NoticeAdapter
import com.learn.xueer.ui.adapter.VipAdapter
import com.learn.xueer.ui.viewmodel.MessageViewModel
import com.learn.xueer.ui.viewmodel.MineViewModel
import me.hgj.jetpackmvvm.util.get

/**
 * 消息
 */
class InnerMessageActivity : BaseActivity<MessageViewModel, ActivityInnerMessageBinding>() {
    private val noticeAdapter: NoticeAdapter by lazy { NoticeAdapter(arrayListOf()) }

    override fun initView(savedInstanceState: Bundle?) {
        mViewModel.messageReq()
        mDatabind.click = ProxyClick()

        mDatabind.rv.adapter=noticeAdapter
        var innerJson = intent.get<String>("data").toString()
        val innerData = Gson().fromJson<MutableList<Notice>>(
            innerJson,
            object : TypeToken<MutableList<Notice>>() {}.type
        )
        noticeAdapter.setList(innerData)
    }

    inner class ProxyClick {
        fun back() {
            finish()
        }
    }
}